package org.tbjd.client.customWidgets;

import java.util.HashMap;

import org.tbjd.client.beans.Task;
import org.tbjd.client.constants.NotificationsConstants;
import org.tbjd.client.exceptions.TBJDException;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Widget;

public class EndDateTextBox extends CustomTextBox {

	public EndDateTextBox(final Task task) {
		super(task);
		mapKey = NotificationsConstants.DATEMANAGER_ACTION_endDate;

		addChangeListener(new ChangeListener() {

			public void onChange(Widget sender) {
				source = sender;

				map = new HashMap<Integer, Object>();
				map.put(NotificationsConstants.DATEMANAGER_BEAN, task);
				map.put(mapKey, DateTimeFormat.getShortDateFormat().parse(getText()));

				try {
					delegate(map);

				} catch (TBJDException e) {
					e.printStackTrace();

				}
			}
		});
	}

}
